@extends('index.layouts.app')
@section('title', '更新个人资料')

@section('content')
  <div class="offset-md-2 col-md-8">
    <div class="card ">
      <div class="card-header">
        <h5>更新个人资料</h5>
      </div>
      <div class="card-body">

        @include('index.shared._errors')

        <div class="gravatar_edit">
          <a href="http://gravatar.com/emails" target="_blank">
            <img src="{{ Auth::user()->avatar }}" alt="{{ $user->name }}" class="gravatar"/>
          </a>
        </div>

        <form action="{{ route('users.update', $user->id) }}" method="POST"
              accept-charset="UTF-8"
              enctype="multipart/form-data">
          {{ method_field('PATCH') }}
          {{ csrf_field() }}
          <div class="form-group">
            <label for="name-field">名称</label>
            <input class="form-control" type="text" name="name" id="name-field" value="{{ old('name', $user->name) }}" />
          </div>
          <div class="form-group mb-4">
            <label for="" class="avatar-label">用户头像</label>
            <input type="file" name="avatar" class="form-control-file">

            @if($user->avatar)
              <br>
              <img class="thumbnail img-responsive" src="{{ $user->avatar }}" width="200" />
            @endif
          </div>
          <div class="form-group">
            <label for="email-field">邮 箱</label>
            <input class="form-control" type="text" name="email" id="email-field" value="{{ old('email', $user->email) }}" disabled/>
          </div>
          <div class="form-group">
            <label for="introduction-field">个人简介</label>
            <textarea name="introduction" id="introduction-field" class="form-control" rows="3">{{ old('introduction', $user->introduction) }}</textarea>
          </div>

          <button type="submit" class="btn btn-primary">更新</button>
        </form>
      </div>
    </div>
  </div>
@stop
